package com.gameserver;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;


public class SocketAccepter implements Runnable {

	ServerSocket mServerSocket;
	Socket accepted;
	
	public SocketAccepter(ServerSocket serverSocket)
	{
		this.mServerSocket = serverSocket;
		accepted = null;
	}
	@Override
	public void run() {
		while(!mServerSocket.isClosed()){
			try {
				accepted = mServerSocket.accept();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public boolean hasSocket()
	{
		return accepted != null;
	}
	
	public Socket getSocket()
	{
		Socket tmp = accepted;
		accepted = null;
		return tmp;
	}

}
